home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Over 1,000 Windows 95 Programs
/
Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso
/
1257
/
su-dde.c_
/
su-dde.c
Wrap
C/C++ Source or Header
|
1997-04-18
|
28KB
|
768 lines
/* EasyCODE(C++) V5.1 01.03.1995 14:09:58
EasyCODE(C++) sample: DDE communication with Program Manager */
/* EasyCODE O
If=horizontal
LevelNumbers=no
LineNumbers=no
ScreenFont=System,,100,1,-13,0,700,0,0,0,0,0,0,1,2,1,34
PrinterFont=Courier,,100,2,-41,0,400,0,0,0,0,0,0,2,1,2,49
LastLevelId=13 */
/* EasyCODE ( 1
DDE communication with Program Manager */
/* EasyCODE ( 13
Definitions */
/*****************************************************************************/
/* */
/* DDE Communication with Program Manager */
/* */
/*****************************************************************************/
#include <stdlib.h> /* Include-files. */
#include <string.h>
#include <ctype.h>
#define NOMINMAX // min(), max() already defined in stdlib.h.
#include <windows.h>
#include <dde.h>
#include "setup.h"
void FAR PASCAL AddProgramToProgMan(HWND);
BOOL FAR PASCAL ProgManDlgProc(HWND,unsigned,WORD,LONG);
void FAR PASCAL DoAddIcons(HWND,PSTR,unsigned,BOOL);
BOOL FAR PASCAL DDESendCommand(HWND, LPSTR *);
void FAR PASCAL DDEProc(HWND,unsigned,WORD,LONG);
BOOL FAR PASCAL FillComboBox (HWND, WORD);
void FAR PASCAL OutOfGlobalHeapSpaceError(HWND);
void FAR PASCAL OutOfLocalHeapSpaceError(HWND);
void FAR PASCAL DDEInitiateError(HWND);
void FAR PASCAL DDEExecuteCommandError(HWND);
void FAR PASCAL DDEAckTimeOutError(HWND);
// --> su-dlg.c
extern void FAR PASCAL CenterPopup(HWND); // center dialog box!
extern int _cdecl DisplayText(HWND,WORD,WORD,WORD,...);
// --> su-lib.c
extern WORD FAR PASCAL GetSetupConfStringSeq(LPSTR,int,LPCSTR,LPSTR,WORD);
extern BOOL FAR PASCAL GetSetupConfBool (LPSTR,BOOL);
extern void FAR PASCAL AddBackslash (LPSTR);
extern BOOL FAR PASCAL SuppressDialog (WORD);
// module-specific defines...
#define MAX_PROGRAMS 0xFFFF /* variable is 'unsigned'. */
#define LEN_PROGMANNAMEBUFFER 256
#define DDE_NO_CONVERSATION 0
#define DDE_INITIATE 1
#define DDE_IDLE 2
#define DDE_WAITINGFORACK 4
#define DDE_TERMINATE 8
#define DDE_TERMINATE_TIMEOUT 3000L /* milliseconds - 3 sec. */
#define DDE_ACK_TIMEOUT 10000L /* milliseconds - 10 sec. */
// module-specific global variables...
static char szCommand1Part1[] = "[CreateGroup("; /* GROUPNAME */
static char szCommand1Part2[] = ")][ShowGroup("; /* GROUPNAME */
static char szCommand1Part3[] = ",1)]";
static char szCommand2Part1[] = "[ReplaceItem(\""; /* APPLNAME */
static char szCommand2Part2[] = "\")]";
static char szCommand3Part1[] = "[AddItem("; /* EXEFILENAME */
static char szCommand3Part2[] = ",\""; /* APPLNAME */
static char szCommand3Part3[] = "\",)]";
static int DDEState = DDE_NO_CONVERSATION;
static HWND hWndProgMan = (HWND)NULL;
static HANDLE hCommand;
static HANDLE hProgmanData = (HANDLE)NULL;
static PSTR pProgmanData = (PSTR)NULL;
/* EasyCODE ) */
/* EasyCODE ( 2
AddProgramToProgMan */
/* EasyCODE F */
//-----------------------------------------------------------------------------
// Inserting installed programs into ProgMan group
//-----------------------------------------------------------------------------
void FAR PASCAL AddProgramToProgMan(HWND hWnd)
{
FARPROC lpprocAddress;
BOOL bRetVal, bError = FALSE;
char szBuffer[LEN_PROGMANNAMEBUFFER];
HANDLE hPrograms = (HANDLE)NULL, oldHandle;
unsigned nPrograms = 0;
PSTR pPrograms;
MSG msg;
DWORD dwDDETimeOut;
ATOM atomAppl, atomTopic;
// ------------------------------------------------------------------------
// Initiate DDE conversation with program manager.
atomAppl = GlobalAddAtom ("PROGMAN");
atomTopic = GlobalAddAtom ("PROGMAN");
hWndProgMan = (HWND)NULL;
DDEState = DDE_INITIATE;
SendMessage (HWND_BROADCAST, WM_DDE_INITIATE, hWnd, MAKELONG (atomAppl, atomTopic));
GlobalDeleteAtom (atomAppl);
GlobalDeleteAtom (atomTopic);
if (DDEState != DDE_INITIATE || hWndProgMan == (HWND)NULL)
{
DDEInitiateError (hWnd);
return;
}
DDEState = DDE_IDLE; // Conversation established.
hPrograms = LocalAlloc(LMEM_MOVEABLE,
(nPrograms+1)*LEN_PROGMANNAMEBUFFER);
if ((hPrograms == (HANDLE)NULL) || // Error allocating memory.
((pPrograms = LocalLock(hPrograms)) == (PSTR)NULL))
{
OutOfLocalHeapSpaceError(hWnd);
goto dde_exit;
}
while (nPrograms < MAX_PROGRAMS && !bError)
{
*szBuffer = '\0'; // Entries start with 1, nPrograms with 0.
GetSetupConfStringSeq(infoStrings.lpszKeyProgManEntry, nPrograms + 1, "",
(LPSTR)szBuffer, sizeof(szBuffer));
strcpy(pPrograms + nPrograms*LEN_PROGMANNAMEBUFFER,szBuffer);
if (*szBuffer == '\0')
{
break;
// No further strings.
}
nPrograms++; // Next string.
oldHandle = hPrograms;
LocalUnlock(hPrograms);
hPrograms = LocalReAlloc(hPrograms, // Resize buffer.
(nPrograms+1)*LEN_PROGMANNAMEBUFFER,
LMEM_MOVEABLE);
if ((hPrograms == (HANDLE)NULL) || // Error allocating memory.
((pPrograms = LocalLock(hPrograms)) == (PSTR)NULL))
{
LocalFree(oldHandle);
OutOfLocalHeapSpaceError(hWnd);
goto dde_exit;
}
}
// Inserting dialog box into ProgMan group.
lpprocAddress=MakeProcInstance((FARPROC)ProgManDlgProc,hInst);
bRetVal=DialogBoxParam(hInst,"PROGMANBOX",hWnd,lpprocAddress,
MAKELONG(pPrograms,0));
FreeProcInstance((FARPROC)lpprocAddress);
if (bRetVal // If desired do it.
)
{
DoAddIcons(hWnd,pPrograms,nPrograms,bReplaceItems);
}
LocalUnlock(hPrograms); // Free allocated memory.
LocalFree (hPrograms);
dde_exit:
// ------------------------------------------------------------------------
// Terminate conversation with program manager.
DDEState = DDE_TERMINATE;
dwDDETimeOut = GetTickCount() + DDE_TERMINATE_TIMEOUT;
PostMessage (hWndProgMan, WM_DDE_TERMINATE, hWnd, 0L);
while (PeekMessage((LPMSG)&msg, (HWND)NULL,
WM_DDE_FIRST, WM_DDE_LAST, PM_REMOVE))
{
// Wait for acknowledge or timeout.
DispatchMessage((LPMSG)&msg);
if ((msg.message == WM_DDE_TERMINATE) ||
(GetTickCount() > dwDDETimeOut))
{
break;
}
}
DDEState = DDE_NO_CONVERSATION;
return;
}
/* EasyCODE ) */
/* EasyCODE ( 3
ProgManDlgProc */
/* EasyCODE F */
//-----------------------------------------------------------------------------
// Dialog box procedure for inserting programs into ProgMan group
//-----------------------------------------------------------------------------
BOOL FAR PASCAL ProgManDlgProc(HWND hDlg, unsigned message,
WORD wParam, LONG lParam)
{
// When inserting icons into a group the name of which exceeds
// 24 characters by way of DDE, the ProgramManager rewrites an error.
#define MAX_GROUPNAME_LEN 24
switch (message)
{
static PSTR pPrograms;
PSTR p;
WORD i;
char szBuffer[LEN_PROGMANNAMEBUFFER];
DWORD dwWinVersion;
case WM_INITDIALOG:
if (strlen(szProgmanGroupName) > MAX_GROUPNAME_LEN)
{
szProgmanGroupName[MAX_GROUPNAME_LEN] = '\0';
}
SetDlgItemText(hDlg,ID_GROUPNAME,(LPSTR)szProgmanGroupName);
SendDlgItemMessage(hDlg,
ID_GROUPNAME,
EM_LIMITTEXT,
min(sizeof(szProgmanGroupName)-1,
MAX_GROUPNAME_LEN),
0L);
FillComboBox(hDlg, ID_GROUPNAME);
pPrograms = (PSTR)LOWORD(lParam);
if (!pPrograms)
{
EndDialog(hDlg,FALSE); // Error.
}
p = pPrograms;
while (*p != '\0')
{
strcpy(szBuffer,p);
*(strchr(szBuffer,':')) = '\0';
SendDlgItemMessage(hDlg,ID_PROGRAMS,
LB_INSERTSTRING,
(WPARAM)-1,(LPARAM)(LPSTR)szBuffer);
p += LEN_PROGMANNAMEBUFFER;
}
SendDlgItemMessage(hDlg,ID_PROGRAMS,LB_SETSEL,TRUE,-1L);
// In Windows version < 3.10 hide check box for replacing icons
dwWinVersion = GetVersion ();
if (((LOBYTE (LOWORD (dwWinVersion)) << 8) + HIBYTE (LOWORD (dwWinVersion)))
< 0x030a)
{
int yPushButtons, yDist, x[3], y[3];
RECT rCtlArr[3], rDlg;
HWND hCtlArr[3];
EnableWindow (GetDlgItem (hDlg, ID_REPLACE_ITEMS), FALSE);
ShowWindow (GetDlgItem (hDlg, ID_REPLACE_ITEMS), SW_HIDE);
yDist = (6 * HIWORD (GetDialogBaseUnits ())) / 8; // y-Distanz fuer Ctls.
GetWindowRect (GetDlgItem (hDlg, ID_PROGRAMS), (LPRECT)&rCtlArr[0]);
yPushButtons = rCtlArr[0].bottom + yDist;
hCtlArr[0] = GetDlgItem (hDlg, ID_TEXT2);
hCtlArr[1] = GetDlgItem (hDlg, ID_OK);
hCtlArr[2] = GetDlgItem (hDlg, ID_CANCEL);
for (i=0; i<3; i++)
{
GetWindowRect (hCtlArr[i], (LPRECT)&rCtlArr[i]);
x[i] = abs (rCtlArr[i].right - rCtlArr[i].left);
y[i] = abs (rCtlArr[i].bottom - rCtlArr[i].top);
rCtlArr[i].top = yPushButtons;
if (i == 0 // The text must be placed a little lower
)
{
rCtlArr[i].top += 4;
}
rCtlArr[i].bottom = rCtlArr[i].top + y[i];
ScreenToClient(hDlg, (LPPOINT)&rCtlArr[i]); // convert left, top.
MoveWindow(hCtlArr[i], // client
rCtlArr[i].left, rCtlArr[i].top,
x[i], y[i],
TRUE);
}
// Adjust window size.
GetWindowRect (hDlg, (LPRECT)&rDlg);
rDlg.bottom = max (rCtlArr[0].bottom, max (rCtlArr[1].bottom, rCtlArr[2].bottom))
+ yDist
+ GetSystemMetrics(SM_CYDLGFRAME);
MoveWindow(hDlg, // screen
rDlg.left, rDlg.top,
abs(rDlg.right-rDlg.left), abs(rDlg.bottom-rDlg.top),
TRUE);
}
else
{
CheckDlgButton (hDlg, ID_REPLACE_ITEMS, bReplaceItems);
}
CenterPopup(hDlg); // Center!
if (SuppressDialog (IDS_KEY_SUPPDLGPROGMAN))
{
PostMessage (hDlg, WM_COMMAND, ID_YES, 0L);
}
else
{
SetFocus(GetDlgItem(hDlg,ID_YES));
}
return (FALSE);
break;
case WM_COMMAND:
switch (wParam)
{
case ID_GROUPNAME:
// Graying of 'Yes' button.
if (HIWORD(lParam) == CBN_EDITCHANGE)
{
EnableWindow(GetDlgItem(hDlg,
ID_YES),
SendDlgItemMessage(hDlg,
ID_GROUPNAME,
WM_GETTEXTLENGTH,
0,
0L) > 0);
}
break;
case ID_REPLACE_ITEMS:
bReplaceItems = !IsDlgButtonChecked (hDlg, wParam);
CheckDlgButton (hDlg, wParam, bReplaceItems);
break;
case ID_YES:
// Inserting the selected programs.
GetDlgItemText(hDlg, // Group name.
ID_GROUPNAME,
(LPSTR)szProgmanGroupName,
sizeof(szProgmanGroupName));
p = pPrograms, i = 0; // Programs.
while (*p != '\0')
{
LONG iRetVal;
iRetVal = SendDlgItemMessage(hDlg,ID_PROGRAMS,
LB_GETSEL,i,0L);
if ((iRetVal == 0) || // Not selected or
(iRetVal == LB_ERR) // error, then delete.
)
{
*p = '\0';
}
p += LEN_PROGMANNAMEBUFFER, i++; // Next entry.
}
EndDialog(hDlg,TRUE);
break;
case ID_NO:
// No inserting/closing of programs (control menu).
EndDialog(hDlg,FALSE); // cancel dialog box.
break;
default:
return (FALSE);
break;
}
break;
default:
break;
}
return (FALSE);
#undef MAX_GROUPNAME_LEN
}
/* EasyCODE ) */
/* EasyCODE ( 4
DoAddIcons */
/* EasyCODE F */
//-----------------------------------------------------------------------------
// Execution of program insertion into ProgMan group
//-----------------------------------------------------------------------------
void FAR PASCAL DoAddIcons(HWND hWnd, PSTR pPrograms, unsigned nPrograms, BOOL bReplaceIcons)
{
unsigned i;
DWORD dwBytesCommand1, dwBytesCommand2, dwBytesCommand3;
LPSTR lpCommand;
BOOL bOk = TRUE;
if (nPrograms == 0 || pPrograms == (PSTR)NULL || *szProgmanGroupName == '\0')
{
return;
}
// ------------------------------------------------------------------------
// Construct commands for inserting programs into program manager group.
dwBytesCommand1 = sizeof (szCommand1Part1) +
sizeof (szProgmanGroupName) +
sizeof (szCommand1Part2) +
sizeof (szProgmanGroupName) +
sizeof (szCommand1Part3);
if (bReplaceIcons)
{
dwBytesCommand2 = sizeof (szCommand2Part1) +
LEN_PROGMANNAMEBUFFER +
sizeof (szCommand2Part2);
}
else
{
dwBytesCommand2 = (DWORD)0;
}
dwBytesCommand3 = sizeof (szCommand3Part1) +
_MAX_PATH +
sizeof (szCommand3Part2) +
LEN_PROGMANNAMEBUFFER +
sizeof (szCommand3Part3);
hCommand = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE,
max(dwBytesCommand1, max(dwBytesCommand2, dwBytesCommand3)));
if ((hCommand == (HANDLE)NULL) ||
((lpCommand = GlobalLock(hCommand)) == (LPSTR)NULL))
{
OutOfGlobalHeapSpaceError(hWnd);
bOk = FALSE;
}
if (bOk)
{
lstrcpy(lpCommand,(LPSTR)szCommand1Part1);
lstrcat(lpCommand,(LPSTR)szProgmanGroupName);
lstrcat(lpCommand,(LPSTR)szCommand1Part2);
lstrcat(lpCommand,(LPSTR)szProgmanGroupName);
lstrcat(lpCommand,(LPSTR)szCommand1Part3);
bOk = DDESendCommand (hWnd, &lpCommand);
}
if (bOk)
{
for (i=0;i<nPrograms;i++ // For all programs.
)
{
PSTR pColon;
if ((*(pPrograms + i*LEN_PROGMANNAMEBUFFER) != '\0') &&
(pColon = strchr(pPrograms+i*LEN_PROGMANNAMEBUFFER,':')))
{
LPSTR p1, p2;
*pColon = '\0'; // Separate string at ':'.
p1 = (LPSTR)(pPrograms + i*LEN_PROGMANNAMEBUFFER); // Before ':'.
p2 = (LPSTR)(pColon + 1); // After ':'.
AnsiUpper(p2); // szDestPath is already uppercase.
if (bReplaceIcons)
{
lstrcpy(lpCommand,(LPSTR)szCommand2Part1); // "[ReplaceItem(\""
lstrcat(lpCommand,(LPSTR)p1); // Application name
lstrcat(lpCommand,(LPSTR)szCommand2Part2); // "\")]
DDESendCommand (hWnd, &lpCommand);
}
lstrcpy(lpCommand,(LPSTR)szCommand3Part1); // "[AddItem("
if (!_fstrpbrk((LPSTR)p2, (LPSTR)"\\/:"))
{
lstrcat(lpCommand,(LPSTR)szDestPath); // Full pathname if no path specified
AddBackslash (lpCommand); // in SETUP.INF
}
lstrcat(lpCommand,(LPSTR)p2); // EXE filename.
lstrcat(lpCommand,(LPSTR)szCommand3Part2);
lstrcat(lpCommand,(LPSTR)p1); // Application name.
lstrcat(lpCommand,(LPSTR)szCommand3Part3);
DDESendCommand (hWnd, &lpCommand);
// if (*pPrograms ... )
}
// for ( ... )
}
// if (!bError)
}
BringWindowToTop(hWnd); // Make setup window top window again!
if (hCommand)
{
GlobalUnlock (hCommand);
GlobalFree (hCommand);
}
return;
}
/* EasyCODE ) */
/* EasyCODE ( 5
DDESendCommand */
/* EasyCODE F */
//---------------------------------------------------------------------------
// DDESendCommand ()
//---------------------------------------------------------------------------
// Sends a DDE command to the Program Manager.
// In: hWnd ... Window handle
// Out: lpCommand ... pointer to command buffer pointer which will be assigned
// again because of "GlobalUnlock()" at the beginning of the
// function and "GlobalLock()" at the end!
// Return: TRUE -> no error occurred.
//---------------------------------------------------------------------------
BOOL FAR PASCAL DDESendCommand (HWND hWnd, LPSTR *lpCommand)
{
MSG msg;
DWORD dwDDETimeOut;
BOOL bOk = TRUE;
GlobalUnlock (hCommand); // Unlock command.
// ------------------------------------------------------------------------
// Send command to program manager for execution.
if (!PostMessage(hWndProgMan, // Post execute command message.
WM_DDE_EXECUTE,
hWnd,
MAKELONG(0,hCommand)))
{
bOk = FALSE;
}
// ------------------------------------------------------------------------
// Wait for acknowledge for command.
if (bOk)
{
DDEState = DDE_WAITINGFORACK;
dwDDETimeOut = GetTickCount() + DDE_ACK_TIMEOUT;
while ((DDEState == DDE_WAITINGFORACK) &&
(GetTickCount() < dwDDETimeOut))
{
// Wait until DDE_ACK or timeout.
if (PeekMessage ((LPMSG)&msg, (HWND)NULL, 0, WM_USER, PM_REMOVE))
{
TranslateMessage ((LPMSG)&msg);
DispatchMessage ((LPMSG)&msg);
}
}
if (DDEState == DDE_WAITINGFORACK // Timeout.
)
{
DDEAckTimeOutError(hWnd);
DDEState = DDE_IDLE;
bOk = FALSE;
}
}
*lpCommand = GlobalLock (hCommand);
return (bOk);
}
/* EasyCODE ) */
/* EasyCODE ( 6
DDEProc */
/* EasyCODE F */
//-----------------------------------------------------------------------------
// Handling of incoming DDE messages
//-----------------------------------------------------------------------------
void FAR PASCAL DDEProc(HWND hWnd, unsigned msg, WORD wParam, LONG lParam)
{
DDEACK ddeAck;
WORD wDummy1, wDummy2, wDataLen;
LPSTR lpStr;
BOOL bRelease;
DDEDATA FAR *lpDDEData;
HGLOBAL hData;
ATOM atomItem;
switch (msg)
{
case WM_DDE_ACK:
// Request accepted.
switch (DDEState)
{
case DDE_INITIATE:
// Conversation accepted?
GlobalDeleteAtom ((ATOM)LOWORD(lParam));
GlobalDeleteAtom ((ATOM)HIWORD(lParam));
if (hWndProgMan == (HWND)NULL // No conversation until yet.
)
{
hWndProgMan = wParam; // Window handle of ProgMan.
}
break;
case DDE_WAITINGFORACK:
// Command accepted?
wDummy1 = LOWORD (lParam);
wDummy2 = HIWORD (lParam);
if (wDummy2 && wDummy2 != hCommand)
{
hCommand = (HANDLE)wDummy2; // Server has created a new memory handle
}
ddeAck = *((DDEACK *)&wDummy1);
if (ddeAck.fAck // Command executed.
)
{
DDEState = DDE_IDLE;
}
else
{
// Error executing command.
/* EasyCODE - */
lpStr = GlobalLock ((HANDLE)wDummy2);
if (!_fstrstr (lpStr, szCommand2Part1) // If "ReplaceItem()" fails,
)
{
DDEExecuteCommandError (hWnd); // no error message output
}
GlobalUnlock ((HANDLE)wDummy2);
DDEState = DDE_IDLE;
}
break;
default:
break;
}
break;
case WM_DDE_DATA:
hData = LOWORD (lParam);
atomItem = HIWORD (lParam);
if (!(lpDDEData = (DDEDATA FAR*)GlobalLock (hData)) ||
(lpDDEData->cfFormat != CF_TEXT))
{
// Send negative acknowledge to server.
PostMessage (hWndProgMan, WM_DDE_ACK, hWnd, MAKELONG (0, atomItem));
pProgmanData = NULL;
}
else
{
wDataLen = lstrlen (lpDDEData->Value);
if ((hProgmanData = LocalAlloc (LMEM_MOVEABLE, wDataLen+1)) == NULL ||
(pProgmanData = LocalLock (hProgmanData)) == NULL)
{
OutOfGlobalHeapSpaceError(hWnd);
}
// Copy DDE data.
lstrcpy ((LPSTR)pProgmanData, lpDDEData->Value);
LocalUnlock (hProgmanData);
if (lpDDEData->fAckReq)
{
PostMessage (hWndProgMan, WM_DDE_ACK, hWnd,
MAKELONG (0x8000, atomItem));
}
bRelease = lpDDEData->fRelease;
GlobalUnlock (hData);
if (bRelease)
{
GlobalFree (hData);
}
}
DDEState = DDE_IDLE;
break;
case WM_DDE_TERMINATE:
if (wParam == hWndProgMan)
{
if (DDEState != DDE_TERMINATE)
{
PostMessage (hWndProgMan, WM_DDE_TERMINATE, hWnd, 0L);
}
DDEState = DDE_NO_CONVERSATION;
}
break;
default:
break;
}
}
/* EasyCODE ) */
/* EasyCODE ( 7
FillComboBox */
/* EasyCODE F */
//---------------------------------------------------------------------------
// FillComboBox ()
//---------------------------------------------------------------------------
// The function determines the names of the existing program groups by
// way of DDE request. These names will then be inserted into the
// list box "idControl" of the dialog box "hDlg".
//---------------------------------------------------------------------------
// Input: hDlg ... dialog box handle
// idControl ... Id of the combobox
// Return: TRUE -> successful insertion; FALSE -> error occurred
//---------------------------------------------------------------------------
BOOL FAR PASCAL FillComboBox (HWND hDlg, WORD idControl)
{
BOOL bOk = TRUE;
ATOM atomAppl;
DWORD dwDDETimeOut;
MSG msg;
PSTR pGroup;
atomAppl = GlobalAddAtom ("PROGMAN");
if (!PostMessage(hWndProgMan, // Post request command message.
WM_DDE_REQUEST,
hWindow,
MAKELONG(CF_TEXT, atomAppl)))
{
GlobalDeleteAtom (atomAppl);
bOk = FALSE;
}
// ------------------------------------------------------------------------
// Wait for acknowledge for command.
if (bOk)
{
DDEState = DDE_WAITINGFORACK;
dwDDETimeOut = GetTickCount() + DDE_ACK_TIMEOUT;
while ((DDEState == DDE_WAITINGFORACK) &&
(GetTickCount() < dwDDETimeOut))
{
// Wait until DDE_ACK or timeout.
if (PeekMessage ((LPMSG)&msg, (HWND)NULL, 0, WM_USER, PM_REMOVE))
{
TranslateMessage ((LPMSG)&msg);
DispatchMessage ((LPMSG)&msg);
}
}
if (DDEState == DDE_WAITINGFORACK // Timeout.
)
{
DDEAckTimeOutError(hWindow);
DDEState = DDE_IDLE;
bOk = FALSE;
}
}
if (bOk && (pProgmanData =(PSTR)LocalLock (hProgmanData)) != NULL)
{
pGroup = strtok (pProgmanData, "\r\n");
while (pGroup)
{
if (strlen (pGroup))
{
SendDlgItemMessage (hDlg, idControl, CB_ADDSTRING, 0, (LPARAM)(LPSTR)pGroup);
}
pGroup = strtok (NULL, "\r\n");
}
}
if (hProgmanData)
{
LocalUnlock (hProgmanData);
hProgmanData = LocalFree (hProgmanData);
}
return bOk;
}
/* EasyCODE ) */
/* EasyCODE ( 8
OutOfGlobalHeapSpaceError */
/* EasyCODE F */
//-----------------------------------------------------------------------------
// Various error messages
//-----------------------------------------------------------------------------
void FAR PASCAL OutOfGlobalHeapSpaceError(HWND hWnd)
{
DisplayText(hWnd, IDS_OUTOFGLOBALHEAPSPACE, 0, MB_ICONEXCLAMATION);
}
/* EasyCODE ) */
/* EasyCODE ( 9
OutOfLocalHeapSpaceError */
/* EasyCODE F */
void FAR PASCAL OutOfLocalHeapSpaceError(HWND hWnd)
{
DisplayText(hWnd, IDS_OUTOFLOCALHEAPSPACE, 0, MB_ICONEXCLAMATION);
}
/* EasyCODE ) */
/* EasyCODE ( 10
DDEInitiateError */
/* EasyCODE F */
void FAR PASCAL DDEInitiateError(HWND hWnd)
{
DisplayText(hWnd, IDS_INITIATEERROR, 0, MB_ICONEXCLAMATION);
}
/* EasyCODE ) */
/* EasyCODE ( 11
DDEExecuteCommandError */
/* EasyCODE F */
void FAR PASCAL DDEExecuteCommandError(HWND hWnd)
{
DisplayText(hWnd, IDS_DDEEEXECERROR, 0, MB_ICONEXCLAMATION);
}
/* EasyCODE ) */
/* EasyCODE ( 12
DDEAckTimeOutError */
/* EasyCODE F */
void FAR PASCAL DDEAckTimeOutError(HWND hWnd)
{
DisplayText(hWnd, IDS_DDEACKTIMEOUT, 0, MB_ICONEXCLAMATION);
}
/* EasyCODE ) */
/* EasyCODE ) */